package org.jay.angla.fragment;

import org.achartengine.GraphicalView;
import org.jay.angla.chart.QAChart;
import org.jay.angla.dialog.QASettingDialog;
import org.jay.angla.onlab.R;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.Spinner;

@SuppressLint("NewApi")
public class FragmentQuantitativeAnalysis extends Fragment implements
		View.OnClickListener {

	private FragmentCallbackListener mListener;
	private FrameLayout mQAChart;
	private QAChart mChart;
	private QASettingDialog mSettingDialog;

	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		mListener = (FragmentCallbackListener) activity;
		super.onAttach(activity);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View rootView = inflater.inflate(
				R.layout.fragment_quantitative_analysis, container, false);

		mQAChart = (FrameLayout) rootView.findViewById(R.id.chart_qa);
		mChart = new QAChart();
		GraphicalView view = mChart.getChartView(getActivity());
		mQAChart.removeAllViews();
		mQAChart.addView(view);
		mChart.add();
		mChart.add();
		mChart.add();

		mSettingDialog = new QASettingDialog(getActivity());
		mSettingDialog.show();

		mSettingDialog.setOnButtonClick(this);
		return rootView;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.btn_dialog_ok:
			mSettingDialog.dismiss();
			break;
		case R.id.btn_dialog_cancel:
			mSettingDialog.dismiss();
			getActivity().getFragmentManager().popBackStack();
			break;
		default:
			break;
		}
	}
}
